<template>
  <div>
    <el-button type="primary" @click="clickAdd">添加</el-button>
    <v-list ref="vList" :list="list" @req="request" @one="one"></v-list>
    <v-from :flag="flag" @request="request" :list="list" :oneList="oneList" ref="vFrom"></v-from>
  </div>
</template>
<script>
import vFrom from "./components/from.vue";
import vList from "./components/list.vue";
import { reqmenulist, reqmenuinfo } from "../../request/api";
export default {
  data() {
    return {
      list: [],
      flag: {
        isshow: false,
        add: true
      },
      oneList: []
    };
  },
  props: [],
  components: { vFrom, vList },
  methods: {
    clickAdd() {
      this.flag.isshow = true;
      this.flag.add = true;
    },
    request() {
      reqmenulist({ istree: true }).then(res => {
        this.list = res.data.list;
      });
    },
    one(id) {
      this.flag.isshow = true;
      this.flag.add = false;
      this.$refs.vFrom.getOne(id)
    }
  },
  mounted() {
    this.request();
  }
};
</script>
<style lang="less" scoped>
.el-button {
  margin: 20px 0;
}
</style>